export const cloneDeep = (obj: any) => {
  if (obj === null || typeof obj !== 'object') {
    return obj
  }
  const copyObj: any = Array.isArray(obj) ? [] : {}

  for (const key in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, key)) {
      copyObj[key] = cloneDeep(obj[key])
    }
  }
  return copyObj
}

export const isEmpty = (value: any) => {
  switch (typeof value) {
    case 'undefined':
      return true
    case 'string':
      if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0)
        return true
      break
    case 'boolean':
      if (!value) return true
      break
    case 'number':
      if (0 === value || isNaN(value)) return true
      break
    case 'object':
      if (null === value || value.length === 0) return true
      for (const i in value) {
        return false
      }
      return true
  }
  return false
}
